# Maintainer: Leandro Nini <drfiemost@email.it>

_realname=libreplaygain
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=475
pkgrel=2
pkgdesc="A library to adjust audio gain (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://musepack.net/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
options=('staticlibs' 'strip')
source=("https://files.musepack.net/source/${_realname}_r${pkgver}.tar.gz"
        "010-no-fpic.patch")
sha512sums=('b5fce8daf6aa8c8e0adb4c80089b43824b6503cb7d11e0c47c779c57a933b32f0c24722ca3fcf49711199fddcbb92c3fc13876f22418ca1521c7b8e27ba9d409'
            '4a552e3d37f03162ca1c30715cd36e2e40c2f5f527bd39c9369fe5c823ad60e65996a2d9f5e13d5d05ccb0df0aa25ca41d68892617528e3132fc1b075bfc1f45')

prepare() {
  cd "${srcdir}"/${_realname}_r${pkgver}
  patch -p1 -i ${srcdir}/010-no-fpic.patch
  autoreconf -i
}

build() {
  [[ -d ${srcdir}/build-${CARCH} ]] && rm -rf ${srcdir}/build-${CARCH}
  mkdir -p "${srcdir}/build-${CARCH}" && cd "${srcdir}/build-${CARCH}"

  ../${_realname}_r${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="${pkgdir}" install
}
